// packageJ/anytime_service/my/index/index.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    authtrue: 1,//角色申请
    is_publish: 1,//发布者：1是0否
    is_shifu: 0,//师傅：1是0否
    is_enterprise: 0,//企业：1是0否
    is_area_agent: 1,//是否区域管理员：1是0否
    member: {},
    imgPath: app.globalData.imgPath,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getData()
  },
  getData() {
    app._getNetWork({
      url: app.getNetAddresss('plugin.be-within-call.frontend.manage.my'),
      success: resdata => {
        let { result, data, msg } = resdata.data;
        if (result) {
          this.setData({
            member: data.member,
            is_publish: data.is_publish,
            is_shifu: data.is_shifu,
            is_enterprise: data.is_enterprise,
            is_area_agent: data.is_area_agent
          })
        } else {
          app.tips(msg);
        }
      }
    })
  },
  goto(e) {
    let url = e.currentTarget.dataset.url;
     if (url == 'Demand') {
      let type = e.currentTarget.dataset.type;
      wx.navigateTo({
        url: `/packageJ/anytime_service/my/${url}/${url}?type=${type}`,
      })
    } else if (url=='skill_order') {
      wx.navigateTo({
        url: '/packageJ/anytime_service/my/skill_order/skill_order?order_type=1',
      })
    }else if(url == 'area_order'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/my/skill_order/skill_order?order_type=2',
      })
    }else if(url=='master_worker'){
      let params = e.currentTarget.dataset.params;
      wx.navigateTo({
        url: `/packageJ/anytime_service/my/role_apply_for/${url}/${url}?apply_type=${params}`,
      })
    }else if(url=='skill_manage'||url=='DemandManage'){
      wx.navigateTo({
        url: `/packageJ/anytime_service/my/${url}/${url}`,
      })
    }else if(url=='promulgator'){
      let role = e.currentTarget.dataset.role;
      wx.navigateTo({
        url: '/packageJ/anytime_service/my/role_apply_for/promulgator/promulgator?role='+role
      })
    }else if(url == 'area_manage'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/my/area_manage/area_manage',
      })
    }else if(url=='enterprise_info'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/enterprise_application/index/index'
      })
    }else if(url=='enterprise_publish'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/enterprise_application/demand_publish/index'
      })
    }else if(url=='demand_management'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/enterprise_application/demand_management/index'
      })
    }else if(url=='enterprise_package'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/enterprise_application/enterprise_package/index'
      })
    }else if(url=='order_manage'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/order/index/index'
      })
    }else if(url=='record'){
      wx.navigateTo({
        url: '/packageJ/anytime_service/record/index',
      })
    }else {
      wx.navigateTo({
        url: `/packageJ/anytime_service/my/role_apply_for/${url}/${url}`,
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})